/*
 *ER/Studio 7.0 SQL Code Generation
 * Company :      xxx
 * Project :      HistoriaLaboral080718.dm1
 * Author :       Miguel Zilli
 *
 * Date Created : Friday, July 25, 2008 22:10:35
 * Target DBMS : Microsoft SQL Server 2005
 */

IF OBJECT_ID('HL_Area_Cursos') IS NOT NULL
BEGIN
    DROP TABLE HL_Area_Cursos
    PRINT '<<< DROPPED TABLE HL_Area_Cursos >>>'
END
go
IF OBJECT_ID('HL_Areas') IS NOT NULL
BEGIN
    DROP TABLE HL_Areas
    PRINT '<<< DROPPED TABLE HL_Areas >>>'
END
go
IF OBJECT_ID('HL_Bienes_x_Microemprendimiento') IS NOT NULL
BEGIN
    DROP TABLE HL_Bienes_x_Microemprendimiento
    PRINT '<<< DROPPED TABLE HL_Bienes_x_Microemprendimiento >>>'
END
go
IF OBJECT_ID('HL_Capacidad_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE HL_Capacidad_x_Persona
    PRINT '<<< DROPPED TABLE HL_Capacidad_x_Persona >>>'
END
go
IF OBJECT_ID('HL_Capacidades') IS NOT NULL
BEGIN
    DROP TABLE HL_Capacidades
    PRINT '<<< DROPPED TABLE HL_Capacidades >>>'
END
go
IF OBJECT_ID('HL_Cargos') IS NOT NULL
BEGIN
    DROP TABLE HL_Cargos
    PRINT '<<< DROPPED TABLE HL_Cargos >>>'
END
go
IF OBJECT_ID('HL_Carnet') IS NOT NULL
BEGIN
    DROP TABLE HL_Carnet
    PRINT '<<< DROPPED TABLE HL_Carnet >>>'
END
go
IF OBJECT_ID('HL_Carnet_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE HL_Carnet_x_Persona
    PRINT '<<< DROPPED TABLE HL_Carnet_x_Persona >>>'
END
go
IF OBJECT_ID('HL_Cobranzas') IS NOT NULL
BEGIN
    DROP TABLE HL_Cobranzas
    PRINT '<<< DROPPED TABLE HL_Cobranzas >>>'
END
go
IF OBJECT_ID('HL_Convenios') IS NOT NULL
BEGIN
    DROP TABLE HL_Convenios
    PRINT '<<< DROPPED TABLE HL_Convenios >>>'
END
go
IF OBJECT_ID('HL_Cursos') IS NOT NULL
BEGIN
    DROP TABLE HL_Cursos
    PRINT '<<< DROPPED TABLE HL_Cursos >>>'
END
go
IF OBJECT_ID('HL_Cursos_Deseados_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE HL_Cursos_Deseados_x_Persona
    PRINT '<<< DROPPED TABLE HL_Cursos_Deseados_x_Persona >>>'
END
go
IF OBJECT_ID('HL_Cursos_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE HL_Cursos_x_Persona
    PRINT '<<< DROPPED TABLE HL_Cursos_x_Persona >>>'
END
go
IF OBJECT_ID('HL_Discapacidad_x_Familiar') IS NOT NULL
BEGIN
    DROP TABLE HL_Discapacidad_x_Familiar
    PRINT '<<< DROPPED TABLE HL_Discapacidad_x_Familiar >>>'
END
go
IF OBJECT_ID('HL_Discapacidad_x_Solicitud') IS NOT NULL
BEGIN
    DROP TABLE HL_Discapacidad_x_Solicitud
    PRINT '<<< DROPPED TABLE HL_Discapacidad_x_Solicitud >>>'
END
go
IF OBJECT_ID('HL_Discapacidades') IS NOT NULL
BEGIN
    DROP TABLE HL_Discapacidades
    PRINT '<<< DROPPED TABLE HL_Discapacidades >>>'
END
go
IF OBJECT_ID('HL_Discapacidades_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE HL_Discapacidades_x_Persona
    PRINT '<<< DROPPED TABLE HL_Discapacidades_x_Persona >>>'
END
go
IF OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') IS NOT NULL
BEGIN
    DROP TABLE HL_Empresa_x_Persona_x_Cargo
    PRINT '<<< DROPPED TABLE HL_Empresa_x_Persona_x_Cargo >>>'
END
go
IF OBJECT_ID('HL_Empresas') IS NOT NULL
BEGIN
    DROP TABLE HL_Empresas
    PRINT '<<< DROPPED TABLE HL_Empresas >>>'
END
go
IF OBJECT_ID('HL_Estudio_x_Solicitud') IS NOT NULL
BEGIN
    DROP TABLE HL_Estudio_x_Solicitud
    PRINT '<<< DROPPED TABLE HL_Estudio_x_Solicitud >>>'
END
go
IF OBJECT_ID('HL_Estudios') IS NOT NULL
BEGIN
    DROP TABLE HL_Estudios
    PRINT '<<< DROPPED TABLE HL_Estudios >>>'
END
go
IF OBJECT_ID('HL_Etapas') IS NOT NULL
BEGIN
    DROP TABLE HL_Etapas
    PRINT '<<< DROPPED TABLE HL_Etapas >>>'
END
go
IF OBJECT_ID('HL_Familiares') IS NOT NULL
BEGIN
    DROP TABLE HL_Familiares
    PRINT '<<< DROPPED TABLE HL_Familiares >>>'
END
go
IF OBJECT_ID('HL_Idioma_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE HL_Idioma_x_Persona
    PRINT '<<< DROPPED TABLE HL_Idioma_x_Persona >>>'
END
go
IF OBJECT_ID('HL_Idiomas') IS NOT NULL
BEGIN
    DROP TABLE HL_Idiomas
    PRINT '<<< DROPPED TABLE HL_Idiomas >>>'
END
go
IF OBJECT_ID('HL_Industrias') IS NOT NULL
BEGIN
    DROP TABLE HL_Industrias
    PRINT '<<< DROPPED TABLE HL_Industrias >>>'
END
go
IF OBJECT_ID('HL_Intereses_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE HL_Intereses_x_Persona
    PRINT '<<< DROPPED TABLE HL_Intereses_x_Persona >>>'
END
go
IF OBJECT_ID('HL_Microemprendimientos') IS NOT NULL
BEGIN
    DROP TABLE HL_Microemprendimientos
    PRINT '<<< DROPPED TABLE HL_Microemprendimientos >>>'
END
go
IF OBJECT_ID('HL_Municipios') IS NOT NULL
BEGIN
    DROP TABLE HL_Municipios
    PRINT '<<< DROPPED TABLE HL_Municipios >>>'
END
go
IF OBJECT_ID('HL_Personas') IS NOT NULL
BEGIN
    DROP TABLE HL_Personas
    PRINT '<<< DROPPED TABLE HL_Personas >>>'
END
go
IF OBJECT_ID('HL_Plan_x_Empresa') IS NOT NULL
BEGIN
    DROP TABLE HL_Plan_x_Empresa
    PRINT '<<< DROPPED TABLE HL_Plan_x_Empresa >>>'
END
go
IF OBJECT_ID('HL_Plan_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE HL_Plan_x_Persona
    PRINT '<<< DROPPED TABLE HL_Plan_x_Persona >>>'
END
go
IF OBJECT_ID('HL_Planes') IS NOT NULL
BEGIN
    DROP TABLE HL_Planes
    PRINT '<<< DROPPED TABLE HL_Planes >>>'
END
go
IF OBJECT_ID('HL_Solicitudes') IS NOT NULL
BEGIN
    DROP TABLE HL_Solicitudes
    PRINT '<<< DROPPED TABLE HL_Solicitudes >>>'
END
go
IF OBJECT_ID('HL_Tipo_Discapacidades') IS NOT NULL
BEGIN
    DROP TABLE HL_Tipo_Discapacidades
    PRINT '<<< DROPPED TABLE HL_Tipo_Discapacidades >>>'
END
go
IF OBJECT_ID('HL_Tipo_Puestos') IS NOT NULL
BEGIN
    DROP TABLE HL_Tipo_Puestos
    PRINT '<<< DROPPED TABLE HL_Tipo_Puestos >>>'
END
go
IF OBJECT_ID('HL_Titulo_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE HL_Titulo_x_Persona
    PRINT '<<< DROPPED TABLE HL_Titulo_x_Persona >>>'
END
go
IF OBJECT_ID('HL_Titulos') IS NOT NULL
BEGIN
    DROP TABLE HL_Titulos
    PRINT '<<< DROPPED TABLE HL_Titulos >>>'
END
go
IF OBJECT_ID('HL_Trabajos_Domesticos') IS NOT NULL
BEGIN
    DROP TABLE HL_Trabajos_Domesticos
    PRINT '<<< DROPPED TABLE HL_Trabajos_Domesticos >>>'
END
go
IF OBJECT_ID('HL_Usuarios') IS NOT NULL
BEGIN
    DROP TABLE HL_Usuarios
    PRINT '<<< DROPPED TABLE HL_Usuarios >>>'
END
go
IF OBJECT_ID('HL_Visita_Solicitud') IS NOT NULL
BEGIN
    DROP TABLE HL_Visita_Solicitud
    PRINT '<<< DROPPED TABLE HL_Visita_Solicitud >>>'
END
go
IF OBJECT_ID('HL_Visitas') IS NOT NULL
BEGIN
    DROP TABLE HL_Visitas
    PRINT '<<< DROPPED TABLE HL_Visitas >>>'
END
go
/* 
 * TABLE: HL_Area_Cursos 
 */

CREATE TABLE HL_Area_Cursos(
    IdAreaCurso      int             IDENTITY(1,1),
    Nombre           varchar(255)    NULL,
    Observaciones    text            NULL,
    CONSTRAINT IdAreaCurso PRIMARY KEY NONCLUSTERED (IdAreaCurso)
)
go



IF OBJECT_ID('HL_Area_Cursos') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Area_Cursos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Area_Cursos >>>'
go

/* 
 * TABLE: HL_Areas 
 */

CREATE TABLE HL_Areas(
    IdAreas        int             IDENTITY(1,1),
    Nombre         varchar(255)    NULL,
    Descripcion    varchar(255)    NULL,
    CONSTRAINT IdAreas PRIMARY KEY NONCLUSTERED (IdAreas)
)
go



IF OBJECT_ID('HL_Areas') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Areas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Areas >>>'
go

/* 
 * TABLE: HL_Bienes_x_Microemprendimiento 
 */

CREATE TABLE HL_Bienes_x_Microemprendimiento(
    IdBienes                 int               IDENTITY(1,1),
    IdMicroemprendimiento    int               NULL,
    Cantidad                 int               NULL,
    Monto                    decimal(18, 2)    NULL,
    Estado                   varchar(255)      NULL,
    Descripcion              varchar(255)      NULL,
    CONSTRAINT IdBienes PRIMARY KEY NONCLUSTERED (IdBienes)
)
go



IF OBJECT_ID('HL_Bienes_x_Microemprendimiento') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Bienes_x_Microemprendimiento >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Bienes_x_Microemprendimiento >>>'
go

/* 
 * TABLE: HL_Capacidad_x_Persona 
 */

CREATE TABLE HL_Capacidad_x_Persona(
    IdCapacidad      int             NOT NULL,
    IdPersona        int             NOT NULL,
    Nivel            varchar(100)    NULL,
    Observaciones    text            NULL,
    CONSTRAINT IdCapacidadIdPersona PRIMARY KEY NONCLUSTERED (IdCapacidad, IdPersona)
)
go



IF OBJECT_ID('HL_Capacidad_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Capacidad_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Capacidad_x_Persona >>>'
go

/* 
 * TABLE: HL_Capacidades 
 */

CREATE TABLE HL_Capacidades(
    IdCapacidad    int             IDENTITY(1,1),
    Nombre         varchar(255)    NULL,
    Descripcion    varchar(255)    NULL,
    CONSTRAINT IdCapacidad PRIMARY KEY NONCLUSTERED (IdCapacidad)
)
go



IF OBJECT_ID('HL_Capacidades') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Capacidades >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Capacidades >>>'
go

/* 
 * TABLE: HL_Cargos 
 */

CREATE TABLE HL_Cargos(
    IdCargos        int             IDENTITY(1,1),
    Nombre          varchar(255)    NULL,
    Descripcion     varchar(255)    NULL,
    IdTipoPuesto    int             NULL,
    CONSTRAINT IdCargos PRIMARY KEY NONCLUSTERED (IdCargos)
)
go



IF OBJECT_ID('HL_Cargos') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Cargos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Cargos >>>'
go

/* 
 * TABLE: HL_Carnet 
 */

CREATE TABLE HL_Carnet(
    IdCarnet         int             IDENTITY(1,1),
    Cnrt             varchar(1)      NULL,
    Categoria        varchar(255)    NULL,
    Observaciones    text            NULL,
    CONSTRAINT IdCarnet PRIMARY KEY NONCLUSTERED (IdCarnet)
)
go



IF OBJECT_ID('HL_Carnet') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Carnet >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Carnet >>>'
go

/* 
 * TABLE: HL_Carnet_x_Persona 
 */

CREATE TABLE HL_Carnet_x_Persona(
    IdCarnet         int             NOT NULL,
    IdPersona        int             NOT NULL,
    Numero           varchar(255)    NULL,
    Observaciones    text            NULL,
    CONSTRAINT IdCarnetIdPersona PRIMARY KEY NONCLUSTERED (IdCarnet, IdPersona)
)
go



IF OBJECT_ID('HL_Carnet_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Carnet_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Carnet_x_Persona >>>'
go

/* 
 * TABLE: HL_Cobranzas 
 */

CREATE TABLE HL_Cobranzas(
    IdCobranza               int               IDENTITY(1,1),
    Fecha                    datetime          NULL,
    Monto                    decimal(18, 2)    NULL,
    Observaciones            text              NULL,
    IdMicroemprendimiento    int               NULL,
    CONSTRAINT IdCobranza PRIMARY KEY NONCLUSTERED (IdCobranza)
)
go



IF OBJECT_ID('HL_Cobranzas') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Cobranzas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Cobranzas >>>'
go

/* 
 * TABLE: HL_Convenios 
 */

CREATE TABLE HL_Convenios(
    IdConvenio    int             IDENTITY(1,1),
    Entidad       varchar(255)    NULL,
    Fecha         datetime        NULL,
    Duracion      int             NULL,
    CONSTRAINT IdConvenio PRIMARY KEY NONCLUSTERED (IdConvenio)
)
go



IF OBJECT_ID('HL_Convenios') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Convenios >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Convenios >>>'
go

/* 
 * TABLE: HL_Cursos 
 */

CREATE TABLE HL_Cursos(
    IdCurso          int             IDENTITY(1,1),
    Nombre           varchar(255)    NULL,
    FechaInicio      datetime        NULL,
    Horario          varchar(255)    NULL,
    Duracion         int             NULL,
    Profesor         varchar(255)    NULL,
    Cupo             int             NULL,
    Lugar            varchar(255)    NULL,
    Observaciones    text            NULL,
    IdConvenio       int             NULL,
    IdAreaCurso      int             NULL,
    CONSTRAINT IdCurso PRIMARY KEY NONCLUSTERED (IdCurso)
)
go



IF OBJECT_ID('HL_Cursos') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Cursos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Cursos >>>'
go

/* 
 * TABLE: HL_Cursos_Deseados_x_Persona 
 */

CREATE TABLE HL_Cursos_Deseados_x_Persona(
    IdCurso          int     NOT NULL,
    IdPersona        int     NOT NULL,
    Observaciones    text    NULL,
    CONSTRAINT IdCursoDeseadoIdPersona PRIMARY KEY NONCLUSTERED (IdCurso, IdPersona)
)
go



IF OBJECT_ID('HL_Cursos_Deseados_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Cursos_Deseados_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Cursos_Deseados_x_Persona >>>'
go

/* 
 * TABLE: HL_Cursos_x_Persona 
 */

CREATE TABLE HL_Cursos_x_Persona(
    IdCurso             int             NOT NULL,
    IdPersona           int             NOT NULL,
    Titulo              varchar(255)    NULL,
    EntidadEducativa    varchar(255)    NULL,
    Competencia         varchar(255)    NULL,
    FechaInicio         datetime        NULL,
    Estado              varchar(255)    NULL,
    CONSTRAINT IdCursoIdPersona PRIMARY KEY NONCLUSTERED (IdCurso, IdPersona)
)
go



IF OBJECT_ID('HL_Cursos_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Cursos_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Cursos_x_Persona >>>'
go

/* 
 * TABLE: HL_Discapacidad_x_Familiar 
 */

CREATE TABLE HL_Discapacidad_x_Familiar(
    IdDiscapacidad    int     NOT NULL,
    IdFamiliar        int     NOT NULL,
    Observaciones     text    NULL,
    CONSTRAINT IdDiscapacidadIdFamiliar PRIMARY KEY NONCLUSTERED (IdDiscapacidad, IdFamiliar)
)
go



IF OBJECT_ID('HL_Discapacidad_x_Familiar') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Discapacidad_x_Familiar >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Discapacidad_x_Familiar >>>'
go

/* 
 * TABLE: HL_Discapacidad_x_Solicitud 
 */

CREATE TABLE HL_Discapacidad_x_Solicitud(
    IdDiscapacidad    int     NOT NULL,
    IdSolicitud       int     NOT NULL,
    Observaciones     text    NULL,
    CONSTRAINT IdDiscapacidadIdSollicitud PRIMARY KEY NONCLUSTERED (IdDiscapacidad, IdSolicitud)
)
go



IF OBJECT_ID('HL_Discapacidad_x_Solicitud') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Discapacidad_x_Solicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Discapacidad_x_Solicitud >>>'
go

/* 
 * TABLE: HL_Discapacidades 
 */

CREATE TABLE HL_Discapacidades(
    IdDiscapacidad        int             IDENTITY(1,1),
    Nombre                varchar(255)    NULL,
    Observaciones         text            NULL,
    IdTipoDiscapacidad    int             NULL,
    CONSTRAINT IdDiscapacidad PRIMARY KEY NONCLUSTERED (IdDiscapacidad)
)
go



IF OBJECT_ID('HL_Discapacidades') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Discapacidades >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Discapacidades >>>'
go

/* 
 * TABLE: HL_Discapacidades_x_Persona 
 */

CREATE TABLE HL_Discapacidades_x_Persona(
    IdDiscapacidad         int             NOT NULL,
    IdPersona              int             NOT NULL,
    EntidadCertificante    varchar(255)    NULL,
    Vencimiento            datetime        NULL,
    Observaciones          text            NULL,
    CONSTRAINT IdDiscapacidadIdPersona PRIMARY KEY NONCLUSTERED (IdDiscapacidad, IdPersona)
)
go



IF OBJECT_ID('HL_Discapacidades_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Discapacidades_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Discapacidades_x_Persona >>>'
go

/* 
 * TABLE: HL_Empresa_x_Persona_x_Cargo 
 */

CREATE TABLE HL_Empresa_x_Persona_x_Cargo(
    IdEmpresa          int             NOT NULL,
    IdPersona          int             NOT NULL,
    IdCargos           int             NOT NULL,
    FechaInicio        datetime        NULL,
    FechaFin           datetime        NULL,
    TareasARealizar    varchar(255)    NULL,
    Fuente             varchar(100)    NULL,
    Estado             varchar(100)    NULL,
    Observaciones      text            NULL,
    IdAreas            int             NULL,
    IdSolicitud        int             NULL,
    CONSTRAINT IdEmpresaIdPersonaIdCargos PRIMARY KEY NONCLUSTERED (IdEmpresa, IdPersona, IdCargos)
)
go



IF OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Empresa_x_Persona_x_Cargo >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Empresa_x_Persona_x_Cargo >>>'
go

/* 
 * TABLE: HL_Empresas 
 */

CREATE TABLE HL_Empresas(
    IdEmpresa           int             IDENTITY(1,1),
    Tamano              varchar(100)    NULL,
    RazonSocial         varchar(255)    NULL,
    Direccion           varchar(255)    NULL,
    Telefono            varchar(100)    NULL,
    Email               varchar(100)    NULL,
    Contacto            varchar(255)    NULL,
    TelefonoContacto    varchar(100)    NULL,
    Agencia             varchar(100)    NULL,
    Baja                varchar(1)      NULL,
    IdIndustria         int             NULL,
    IdMunicipio         int             NULL,
    CONSTRAINT IdEmpresa PRIMARY KEY NONCLUSTERED (IdEmpresa)
)
go



IF OBJECT_ID('HL_Empresas') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Empresas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Empresas >>>'
go

/* 
 * TABLE: HL_Estudio_x_Solicitud 
 */

CREATE TABLE HL_Estudio_x_Solicitud(
    IdTitulo         int     NOT NULL,
    IdSolicitud      int     NOT NULL,
    Observaciones    text    NULL,
    CONSTRAINT IdTituloIdSolicitud PRIMARY KEY NONCLUSTERED (IdTitulo, IdSolicitud)
)
go



IF OBJECT_ID('HL_Estudio_x_Solicitud') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Estudio_x_Solicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Estudio_x_Solicitud >>>'
go

/* 
 * TABLE: HL_Estudios 
 */

CREATE TABLE HL_Estudios(
    IdEstudio        int             IDENTITY(1,1),
    Nivel            varchar(100)    NULL,
    Observaciones    text            NULL,
    CONSTRAINT IdEstudio PRIMARY KEY NONCLUSTERED (IdEstudio)
)
go



IF OBJECT_ID('HL_Estudios') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Estudios >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Estudios >>>'
go

/* 
 * TABLE: HL_Etapas 
 */

CREATE TABLE HL_Etapas(
    IdEtapas                 int             IDENTITY(1,1),
    Nombre                   varchar(255)    NULL,
    FechaEntrada             datetime        NULL,
    FechaSalida              datetime        NULL,
    Estado                   varchar(100)    NULL,
    Observaciones            text            NULL,
    IdMicroemprendimiento    int             NULL,
    CONSTRAINT IdEtapas PRIMARY KEY NONCLUSTERED (IdEtapas)
)
go



IF OBJECT_ID('HL_Etapas') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Etapas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Etapas >>>'
go

/* 
 * TABLE: HL_Familiares 
 */

CREATE TABLE HL_Familiares(
    IdFamiliar       int             IDENTITY(1,1),
    Nombre           varchar(255)    NULL,
    Apellido         varchar(255)    NULL,
    Parentesco       varchar(255)    NULL,
    ACargo           varchar(1)      NULL,
    Trabaja          varchar(1)      NULL,
    Estudia          varchar(1)      NULL,
    Edad             int             NULL,
    Observaciones    text            NULL,
    IdPersona        int             NULL,
    CONSTRAINT IdFamiliar PRIMARY KEY NONCLUSTERED (IdFamiliar)
)
go



IF OBJECT_ID('HL_Familiares') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Familiares >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Familiares >>>'
go

/* 
 * TABLE: HL_Idioma_x_Persona 
 */

CREATE TABLE HL_Idioma_x_Persona(
    IdIdioma         int             NOT NULL,
    IdPersona        int             NOT NULL,
    Nivel            varchar(100)    NULL,
    Observaciones    text            NULL,
    CONSTRAINT IdIdiomaIdPersona PRIMARY KEY NONCLUSTERED (IdIdioma, IdPersona)
)
go



IF OBJECT_ID('HL_Idioma_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Idioma_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Idioma_x_Persona >>>'
go

/* 
 * TABLE: HL_Idiomas 
 */

CREATE TABLE HL_Idiomas(
    IdIdioma         int             IDENTITY(1,1),
    Nombre           varchar(255)    NULL,
    Observaciones    text            NULL,
    CONSTRAINT IdIdioma PRIMARY KEY NONCLUSTERED (IdIdioma)
)
go



IF OBJECT_ID('HL_Idiomas') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Idiomas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Idiomas >>>'
go

/* 
 * TABLE: HL_Industrias 
 */

CREATE TABLE HL_Industrias(
    IdIndustria      int             IDENTITY(1,1),
    Nombre           varchar(255)    NULL,
    Observaciones    text            NULL,
    CONSTRAINT IdIndustria PRIMARY KEY NONCLUSTERED (IdIndustria)
)
go



IF OBJECT_ID('HL_Industrias') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Industrias >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Industrias >>>'
go

/* 
 * TABLE: HL_Intereses_x_Persona 
 */

CREATE TABLE HL_Intereses_x_Persona(
    IdPersona        int     NOT NULL,
    IdAreas          int     NOT NULL,
    Observaciones    text    NULL,
    CONSTRAINT IdPersonaIdAreas PRIMARY KEY NONCLUSTERED (IdPersona, IdAreas)
)
go



IF OBJECT_ID('HL_Intereses_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Intereses_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Intereses_x_Persona >>>'
go

/* 
 * TABLE: HL_Microemprendimientos 
 */

CREATE TABLE HL_Microemprendimientos(
    IdMicroemprendimiento      int               IDENTITY(1,1),
    Nombre                     varchar(255)      NULL,
    Propuesta                  varchar(255)      NULL,
    FechaLanzamiento           datetime          NULL,
    Antiguedad                 int               NULL,
    Direccion                  varchar(255)      NULL,
    SituacionDelTerreno        varchar(100)      NULL,
    Participantes              int               NULL,
    ParticipantesFamiliares    int               NULL,
    Asistencia                 varchar(255)      NULL,
    Capacitacion               varchar(255)      NULL,
    DescripcionCapacitacion    varchar(255)      NULL,
    MontoAsignado              decimal(18, 2)    NULL,
    FirmaConvenio              datetime          NULL,
    FechaTransferencia         datetime          NULL,
    PlanCuotas                 int               NULL,
    PromedioFacturacion        decimal(18, 2)    NULL,
    IdMunicipio                int               NULL,
    IdIndustria                int               NULL,
    IdPersona                  int               NULL,
    CONSTRAINT IdMicroemprendimiento PRIMARY KEY NONCLUSTERED (IdMicroemprendimiento)
)
go



IF OBJECT_ID('HL_Microemprendimientos') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Microemprendimientos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Microemprendimientos >>>'
go

/* 
 * TABLE: HL_Municipios 
 */

CREATE TABLE HL_Municipios(
    IdMunicipio    int             IDENTITY(1,1),
    Nombre         varchar(255)    NULL,
    Codigo         varchar(100)    NULL,
    CONSTRAINT IdMunicipio PRIMARY KEY NONCLUSTERED (IdMunicipio)
)
go



IF OBJECT_ID('HL_Municipios') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Municipios >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Municipios >>>'
go

/* 
 * TABLE: HL_Personas 
 */

CREATE TABLE HL_Personas(
    IdPersona            int             IDENTITY(1,1),
    TipoDocumento        varchar(100)    NULL,
    NumeroDocumento      int             NULL,
    Nombre               varchar(255)    NULL,
    Apellido             varchar(255)    NULL,
    DomicilioReal        varchar(255)    NULL,
    DomicilioActual      varchar(255)    NULL,
    Sexo                 varchar(1)      NULL,
    FechaNacimiento      datetime        NULL,
    EstadoCivil          varchar(255)    NULL,
    Cuil                 varchar(100)    NULL,
    Cuit                 varchar(100)    NULL,
    Telefono             varchar(100)    NULL,
    Email                varchar(100)    NULL,
    Vivienda             varchar(255)    NULL,
    Cloaca               varchar(1)      NULL,
    Agua                 varchar(1)      NULL,
    AsistenciaMedica     varchar(255)    NULL,
    Vehiculo             varchar(1)      NULL,
    Movilidad            varchar(1)      NULL,
    BuscaTrabajo         varchar(1)      NULL,
    EstadoLaboral        varchar(1)      NULL,
    Pension              varchar(255)    NULL,
    Baja                 varchar(1)      NULL,
    Observaciones        text            NULL,
    EmpleadoDomestico    varchar(1)      NULL,
    IdMunicipio          int             NULL,
    CONSTRAINT IdPersona PRIMARY KEY NONCLUSTERED (IdPersona)
)
go



IF OBJECT_ID('HL_Personas') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Personas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Personas >>>'
go

/* 
 * TABLE: HL_Plan_x_Empresa 
 */

CREATE TABLE HL_Plan_x_Empresa(
    IdPlan             int         NOT NULL,
    IdEmpresa          int         NOT NULL,
    Participantes      int         NULL,
    FechaSolicitud     datetime    NULL,
    FechaAsignacion    datetime    NULL,
    Observaciones      text        NULL,
    CONSTRAINT IdPlanIdEmpresa PRIMARY KEY NONCLUSTERED (IdPlan, IdEmpresa)
)
go



IF OBJECT_ID('HL_Plan_x_Empresa') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Plan_x_Empresa >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Plan_x_Empresa >>>'
go

/* 
 * TABLE: HL_Plan_x_Persona 
 */

CREATE TABLE HL_Plan_x_Persona(
    IdPlan                     int             NOT NULL,
    IdPersona                  int             NOT NULL,
    FechaAdjudicacion          datetime        NULL,
    FechaBaja                  datetime        NULL,
    Contraprestacion           varchar(255)    NULL,
    LugarDeContraprestacion    varchar(255)    NULL,
    Observaciones              text            NULL,
    CONSTRAINT IdPlanIdPersona PRIMARY KEY NONCLUSTERED (IdPlan, IdPersona)
)
go



IF OBJECT_ID('HL_Plan_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Plan_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Plan_x_Persona >>>'
go

/* 
 * TABLE: HL_Planes 
 */

CREATE TABLE HL_Planes(
    IdPlan         int             IDENTITY(1,1),
    Alcance        varchar(100)    NULL,
    Nombre         varchar(255)    NULL,
    Descripcion    varchar(255)    NULL,
    CONSTRAINT IdPlan PRIMARY KEY NONCLUSTERED (IdPlan)
)
go



IF OBJECT_ID('HL_Planes') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Planes >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Planes >>>'
go

/* 
 * TABLE: HL_Solicitudes 
 */

CREATE TABLE HL_Solicitudes(
    IdSolicitud            int               IDENTITY(1,1),
    ConvenioLaboral        varchar(255)      NULL,
    FechaSolicitud         datetime          NULL,
    TiempoTrabajo          varchar(255)      NULL,
    Sexo                   varchar(1)        NULL,
    CantidadPuestos        int               NULL,
    EdadMinima             int               NULL,
    EdadMaxima             int               NULL,
    TareasARealizar        varchar(255)      NULL,
    UbicacionTrabajo       varchar(255)      NULL,
    Salario                decimal(18, 2)    NULL,
    Beneficios             varchar(255)      NULL,
    DireccionEntrevista    varchar(255)      NULL,
    Contacto               varchar(255)      NULL,
    FormaContrato          varchar(255)      NULL,
    ObservacionesOferta    text              NULL,
    Observaciones          text              NULL,
    IdAreas                int               NULL,
    IdMunicipio            int               NULL,
    IdCargos               int               NULL,
    IdEmpresa              int               NULL,
    CONSTRAINT IdSolicitud PRIMARY KEY NONCLUSTERED (IdSolicitud)
)
go



IF OBJECT_ID('HL_Solicitudes') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Solicitudes >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Solicitudes >>>'
go

/* 
 * TABLE: HL_Tipo_Discapacidades 
 */

CREATE TABLE HL_Tipo_Discapacidades(
    IdTipoDiscapacidad    int             IDENTITY(1,1),
    Nombre                varchar(255)    NULL,
    Observaciones         text            NULL,
    CONSTRAINT IdTipoDiscapacidad PRIMARY KEY NONCLUSTERED (IdTipoDiscapacidad)
)
go



IF OBJECT_ID('HL_Tipo_Discapacidades') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Tipo_Discapacidades >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Tipo_Discapacidades >>>'
go

/* 
 * TABLE: HL_Tipo_Puestos 
 */

CREATE TABLE HL_Tipo_Puestos(
    IdTipoPuesto    int             IDENTITY(1,1),
    Nombre          varchar(255)    NULL,
    Descripcion     varchar(255)    NULL,
    CONSTRAINT IdTipoPuesto PRIMARY KEY NONCLUSTERED (IdTipoPuesto)
)
go



IF OBJECT_ID('HL_Tipo_Puestos') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Tipo_Puestos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Tipo_Puestos >>>'
go

/* 
 * TABLE: HL_Titulo_x_Persona 
 */

CREATE TABLE HL_Titulo_x_Persona(
    IdTitulo            int             NOT NULL,
    IdPersona           int             NOT NULL,
    EntidadEducativa    varchar(255)    NULL,
    FehcaIngreso        datetime        NULL,
    FechaEgreso         datetime        NULL,
    Completo            varchar(1)      NULL,
    CONSTRAINT IdTituloIdPersona PRIMARY KEY NONCLUSTERED (IdTitulo, IdPersona)
)
go



IF OBJECT_ID('HL_Titulo_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Titulo_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Titulo_x_Persona >>>'
go

/* 
 * TABLE: HL_Titulos 
 */

CREATE TABLE HL_Titulos(
    IdTitulo        int             NOT NULL,
    IdEstudio       int             NULL,
    Nombre          varchar(255)    NULL,
    Competencias    varchar(255)    NULL,
    CONSTRAINT IdTitulo PRIMARY KEY NONCLUSTERED (IdTitulo)
)
go



IF OBJECT_ID('HL_Titulos') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Titulos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Titulos >>>'
go

/* 
 * TABLE: HL_Trabajos_Domesticos 
 */

CREATE TABLE HL_Trabajos_Domesticos(
    IdTrabajoDomestico    int               IDENTITY(1,1),
    CUIL                  varchar(100)      NULL,
    Empleador             varchar(255)      NULL,
    Domicilio             varchar(255)      NULL,
    FechaIngreso          datetime          NULL,
    FechaEgreso           datetime          NULL,
    Remuneracion          decimal(18, 2)    NULL,
    Categoria             varchar(255)      NULL,
    Actividad             varchar(255)      NULL,
    Agencia               varchar(1)        NULL,
    Estado                datetime          NULL,
    IdPersona             int               NULL,
    IdEmpresa             int               NULL,
    CONSTRAINT IdTrabajoDomestico PRIMARY KEY NONCLUSTERED (IdTrabajoDomestico)
)
go



IF OBJECT_ID('HL_Trabajos_Domesticos') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Trabajos_Domesticos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Trabajos_Domesticos >>>'
go

/* 
 * TABLE: HL_Usuarios 
 */

CREATE TABLE HL_Usuarios(
    idUsuario        int             IDENTITY(1,1),
    Nombre           varchar(100)    NULL,
    Password         varchar(10)     NULL,
    Persmisos        int             NULL,
    Observaciones    varchar(255)    NULL,
    IdMunicipio      int             NULL,
    CONSTRAINT IdUsuario PRIMARY KEY NONCLUSTERED (idUsuario)
)
go



IF OBJECT_ID('HL_Usuarios') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Usuarios >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Usuarios >>>'
go

/* 
 * TABLE: HL_Visita_Solicitud 
 */

CREATE TABLE HL_Visita_Solicitud(
    IdVisitasSolicitud    int             IDENTITY(1,1),
    RazonVisita           varchar(255)    NULL,
    FechaProgramada       datetime        NULL,
    FechaVisita           datetime        NULL,
    Observaciones         text            NULL,
    IdSolicitud           int             NULL,
    IdEmpresa             int             NULL,
    CONSTRAINT IdVisitaSolicitud PRIMARY KEY NONCLUSTERED (IdVisitasSolicitud)
)
go



IF OBJECT_ID('HL_Visita_Solicitud') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Visita_Solicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Visita_Solicitud >>>'
go

/* 
 * TABLE: HL_Visitas 
 */

CREATE TABLE HL_Visitas(
    IdVisita           int             IDENTITY(1,1),
    Visitador          varchar(255)    NULL,
    FehcaProgramada    datetime        NULL,
    FechaVisita        datetime        NULL,
    Estado             varchar(100)    NULL,
    Observaciones      text            NULL,
    IdEtapas           int             NULL,
    CONSTRAINT IdVisita PRIMARY KEY NONCLUSTERED (IdVisita)
)
go



IF OBJECT_ID('HL_Visitas') IS NOT NULL
    PRINT '<<< CREATED TABLE HL_Visitas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE HL_Visitas >>>'
go

/* 
 * INDEX: IdMicroemprendimiento 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Bienes_x_Microemprendimiento') AND name='IdMicroemprendimiento')
BEGIN
    DROP INDEX HL_Bienes_x_Microemprendimiento.IdMicroemprendimiento
    PRINT '<<< DROPPED INDEX HL_Bienes_x_Microemprendimiento.IdMicroemprendimiento >>>'
END
go

/* 
 * INDEX: IdMicroemprendimiento 
 */

CREATE INDEX IdMicroemprendimiento ON HL_Bienes_x_Microemprendimiento(IdMicroemprendimiento)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Bienes_x_Microemprendimiento') AND name='IdMicroemprendimiento')
    PRINT '<<< CREATED INDEX HL_Bienes_x_Microemprendimiento.IdMicroemprendimiento >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Bienes_x_Microemprendimiento.IdMicroemprendimiento >>>'
go

/* 
 * INDEX: IdCapacidad 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Capacidad_x_Persona') AND name='IdCapacidad')
BEGIN
    DROP INDEX HL_Capacidad_x_Persona.IdCapacidad
    PRINT '<<< DROPPED INDEX HL_Capacidad_x_Persona.IdCapacidad >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Capacidad_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Capacidad_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX HL_Capacidad_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdCapacidad 
 */

CREATE INDEX IdCapacidad ON HL_Capacidad_x_Persona(IdCapacidad)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Capacidad_x_Persona') AND name='IdCapacidad')
    PRINT '<<< CREATED INDEX HL_Capacidad_x_Persona.IdCapacidad >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Capacidad_x_Persona.IdCapacidad >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Capacidad_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Capacidad_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Capacidad_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Capacidad_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdTipoPuesto 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cargos') AND name='IdTipoPuesto')
BEGIN
    DROP INDEX HL_Cargos.IdTipoPuesto
    PRINT '<<< DROPPED INDEX HL_Cargos.IdTipoPuesto >>>'
END
go

/* 
 * INDEX: IdTipoPuesto 
 */

CREATE INDEX IdTipoPuesto ON HL_Cargos(IdTipoPuesto)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cargos') AND name='IdTipoPuesto')
    PRINT '<<< CREATED INDEX HL_Cargos.IdTipoPuesto >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Cargos.IdTipoPuesto >>>'
go

/* 
 * INDEX: IdCarnet 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Carnet_x_Persona') AND name='IdCarnet')
BEGIN
    DROP INDEX HL_Carnet_x_Persona.IdCarnet
    PRINT '<<< DROPPED INDEX HL_Carnet_x_Persona.IdCarnet >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Carnet_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Carnet_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX HL_Carnet_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdCarnet 
 */

CREATE INDEX IdCarnet ON HL_Carnet_x_Persona(IdCarnet)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Carnet_x_Persona') AND name='IdCarnet')
    PRINT '<<< CREATED INDEX HL_Carnet_x_Persona.IdCarnet >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Carnet_x_Persona.IdCarnet >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Carnet_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Carnet_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Carnet_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Carnet_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdMicroempremdimiento 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cobranzas') AND name='IdMicroempremdimiento')
BEGIN
    DROP INDEX HL_Cobranzas.IdMicroempremdimiento
    PRINT '<<< DROPPED INDEX HL_Cobranzas.IdMicroempremdimiento >>>'
END
go

/* 
 * INDEX: IdMicroempremdimiento 
 */

CREATE INDEX IdMicroempremdimiento ON HL_Cobranzas(IdMicroemprendimiento)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cobranzas') AND name='IdMicroempremdimiento')
    PRINT '<<< CREATED INDEX HL_Cobranzas.IdMicroempremdimiento >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Cobranzas.IdMicroempremdimiento >>>'
go

/* 
 * INDEX: IdAreaCurso 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos') AND name='IdAreaCurso')
BEGIN
    DROP INDEX HL_Cursos.IdAreaCurso
    PRINT '<<< DROPPED INDEX HL_Cursos.IdAreaCurso >>>'
END
go

/* 
 * INDEX: IdConvenio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos') AND name='IdConvenio')
BEGIN
    DROP INDEX HL_Cursos.IdConvenio
    PRINT '<<< DROPPED INDEX HL_Cursos.IdConvenio >>>'
END
go

/* 
 * INDEX: IdAreaCurso 
 */

CREATE INDEX IdAreaCurso ON HL_Cursos(IdAreaCurso)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos') AND name='IdAreaCurso')
    PRINT '<<< CREATED INDEX HL_Cursos.IdAreaCurso >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Cursos.IdAreaCurso >>>'
go

/* 
 * INDEX: IdConvenio 
 */

CREATE INDEX IdConvenio ON HL_Cursos(IdConvenio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos') AND name='IdConvenio')
    PRINT '<<< CREATED INDEX HL_Cursos.IdConvenio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Cursos.IdConvenio >>>'
go

/* 
 * INDEX: IdCurso 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos_Deseados_x_Persona') AND name='IdCurso')
BEGIN
    DROP INDEX HL_Cursos_Deseados_x_Persona.IdCurso
    PRINT '<<< DROPPED INDEX HL_Cursos_Deseados_x_Persona.IdCurso >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos_Deseados_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Cursos_Deseados_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX HL_Cursos_Deseados_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdCurso 
 */

CREATE INDEX IdCurso ON HL_Cursos_Deseados_x_Persona(IdCurso)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos_Deseados_x_Persona') AND name='IdCurso')
    PRINT '<<< CREATED INDEX HL_Cursos_Deseados_x_Persona.IdCurso >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Cursos_Deseados_x_Persona.IdCurso >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Cursos_Deseados_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos_Deseados_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Cursos_Deseados_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Cursos_Deseados_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdCurso 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos_x_Persona') AND name='IdCurso')
BEGIN
    DROP INDEX HL_Cursos_x_Persona.IdCurso
    PRINT '<<< DROPPED INDEX HL_Cursos_x_Persona.IdCurso >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Cursos_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX HL_Cursos_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdCurso 
 */

CREATE INDEX IdCurso ON HL_Cursos_x_Persona(IdCurso)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos_x_Persona') AND name='IdCurso')
    PRINT '<<< CREATED INDEX HL_Cursos_x_Persona.IdCurso >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Cursos_x_Persona.IdCurso >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Cursos_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Cursos_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Cursos_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Cursos_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdDiscapacidad 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidad_x_Familiar') AND name='IdDiscapacidad')
BEGIN
    DROP INDEX HL_Discapacidad_x_Familiar.IdDiscapacidad
    PRINT '<<< DROPPED INDEX HL_Discapacidad_x_Familiar.IdDiscapacidad >>>'
END
go

/* 
 * INDEX: IdFamiliar 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidad_x_Familiar') AND name='IdFamiliar')
BEGIN
    DROP INDEX HL_Discapacidad_x_Familiar.IdFamiliar
    PRINT '<<< DROPPED INDEX HL_Discapacidad_x_Familiar.IdFamiliar >>>'
END
go

/* 
 * INDEX: IdDiscapacidad 
 */

CREATE INDEX IdDiscapacidad ON HL_Discapacidad_x_Familiar(IdDiscapacidad)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidad_x_Familiar') AND name='IdDiscapacidad')
    PRINT '<<< CREATED INDEX HL_Discapacidad_x_Familiar.IdDiscapacidad >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Discapacidad_x_Familiar.IdDiscapacidad >>>'
go

/* 
 * INDEX: IdFamiliar 
 */

CREATE INDEX IdFamiliar ON HL_Discapacidad_x_Familiar(IdFamiliar)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidad_x_Familiar') AND name='IdFamiliar')
    PRINT '<<< CREATED INDEX HL_Discapacidad_x_Familiar.IdFamiliar >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Discapacidad_x_Familiar.IdFamiliar >>>'
go

/* 
 * INDEX: IdDiscapacidad 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidad_x_Solicitud') AND name='IdDiscapacidad')
BEGIN
    DROP INDEX HL_Discapacidad_x_Solicitud.IdDiscapacidad
    PRINT '<<< DROPPED INDEX HL_Discapacidad_x_Solicitud.IdDiscapacidad >>>'
END
go

/* 
 * INDEX: IdSolicitud 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidad_x_Solicitud') AND name='IdSolicitud')
BEGIN
    DROP INDEX HL_Discapacidad_x_Solicitud.IdSolicitud
    PRINT '<<< DROPPED INDEX HL_Discapacidad_x_Solicitud.IdSolicitud >>>'
END
go

/* 
 * INDEX: IdDiscapacidad 
 */

CREATE INDEX IdDiscapacidad ON HL_Discapacidad_x_Solicitud(IdDiscapacidad)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidad_x_Solicitud') AND name='IdDiscapacidad')
    PRINT '<<< CREATED INDEX HL_Discapacidad_x_Solicitud.IdDiscapacidad >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Discapacidad_x_Solicitud.IdDiscapacidad >>>'
go

/* 
 * INDEX: IdSolicitud 
 */

CREATE INDEX IdSolicitud ON HL_Discapacidad_x_Solicitud(IdSolicitud)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidad_x_Solicitud') AND name='IdSolicitud')
    PRINT '<<< CREATED INDEX HL_Discapacidad_x_Solicitud.IdSolicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Discapacidad_x_Solicitud.IdSolicitud >>>'
go

/* 
 * INDEX: IdTipoDiscapacidad 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidades') AND name='IdTipoDiscapacidad')
BEGIN
    DROP INDEX HL_Discapacidades.IdTipoDiscapacidad
    PRINT '<<< DROPPED INDEX HL_Discapacidades.IdTipoDiscapacidad >>>'
END
go

/* 
 * INDEX: IdTipoDiscapacidad 
 */

CREATE INDEX IdTipoDiscapacidad ON HL_Discapacidades(IdTipoDiscapacidad)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidades') AND name='IdTipoDiscapacidad')
    PRINT '<<< CREATED INDEX HL_Discapacidades.IdTipoDiscapacidad >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Discapacidades.IdTipoDiscapacidad >>>'
go

/* 
 * INDEX: IdDiscapacidad 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidades_x_Persona') AND name='IdDiscapacidad')
BEGIN
    DROP INDEX HL_Discapacidades_x_Persona.IdDiscapacidad
    PRINT '<<< DROPPED INDEX HL_Discapacidades_x_Persona.IdDiscapacidad >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidades_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Discapacidades_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX HL_Discapacidades_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdDiscapacidad 
 */

CREATE INDEX IdDiscapacidad ON HL_Discapacidades_x_Persona(IdDiscapacidad)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidades_x_Persona') AND name='IdDiscapacidad')
    PRINT '<<< CREATED INDEX HL_Discapacidades_x_Persona.IdDiscapacidad >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Discapacidades_x_Persona.IdDiscapacidad >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Discapacidades_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Discapacidades_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Discapacidades_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Discapacidades_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdCargos 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') AND name='IdCargos')
BEGIN
    DROP INDEX HL_Empresa_x_Persona_x_Cargo.IdCargos
    PRINT '<<< DROPPED INDEX HL_Empresa_x_Persona_x_Cargo.IdCargos >>>'
END
go

/* 
 * INDEX: IdAreas 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') AND name='IdAreas')
BEGIN
    DROP INDEX HL_Empresa_x_Persona_x_Cargo.IdAreas
    PRINT '<<< DROPPED INDEX HL_Empresa_x_Persona_x_Cargo.IdAreas >>>'
END
go

/* 
 * INDEX: IdSolicitud 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') AND name='IdSolicitud')
BEGIN
    DROP INDEX HL_Empresa_x_Persona_x_Cargo.IdSolicitud
    PRINT '<<< DROPPED INDEX HL_Empresa_x_Persona_x_Cargo.IdSolicitud >>>'
END
go

/* 
 * INDEX: IdEmpresa 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') AND name='IdEmpresa')
BEGIN
    DROP INDEX HL_Empresa_x_Persona_x_Cargo.IdEmpresa
    PRINT '<<< DROPPED INDEX HL_Empresa_x_Persona_x_Cargo.IdEmpresa >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Empresa_x_Persona_x_Cargo.IdPersona
    PRINT '<<< DROPPED INDEX HL_Empresa_x_Persona_x_Cargo.IdPersona >>>'
END
go

/* 
 * INDEX: IdCargos 
 */

CREATE INDEX IdCargos ON HL_Empresa_x_Persona_x_Cargo(IdCargos)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') AND name='IdCargos')
    PRINT '<<< CREATED INDEX HL_Empresa_x_Persona_x_Cargo.IdCargos >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Empresa_x_Persona_x_Cargo.IdCargos >>>'
go

/* 
 * INDEX: IdAreas 
 */

CREATE INDEX IdAreas ON HL_Empresa_x_Persona_x_Cargo(IdAreas)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') AND name='IdAreas')
    PRINT '<<< CREATED INDEX HL_Empresa_x_Persona_x_Cargo.IdAreas >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Empresa_x_Persona_x_Cargo.IdAreas >>>'
go

/* 
 * INDEX: IdSolicitud 
 */

CREATE INDEX IdSolicitud ON HL_Empresa_x_Persona_x_Cargo(IdSolicitud)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') AND name='IdSolicitud')
    PRINT '<<< CREATED INDEX HL_Empresa_x_Persona_x_Cargo.IdSolicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Empresa_x_Persona_x_Cargo.IdSolicitud >>>'
go

/* 
 * INDEX: IdEmpresa 
 */

CREATE INDEX IdEmpresa ON HL_Empresa_x_Persona_x_Cargo(IdEmpresa)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') AND name='IdEmpresa')
    PRINT '<<< CREATED INDEX HL_Empresa_x_Persona_x_Cargo.IdEmpresa >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Empresa_x_Persona_x_Cargo.IdEmpresa >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Empresa_x_Persona_x_Cargo(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresa_x_Persona_x_Cargo') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Empresa_x_Persona_x_Cargo.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Empresa_x_Persona_x_Cargo.IdPersona >>>'
go

/* 
 * INDEX: IdIndustria 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresas') AND name='IdIndustria')
BEGIN
    DROP INDEX HL_Empresas.IdIndustria
    PRINT '<<< DROPPED INDEX HL_Empresas.IdIndustria >>>'
END
go

/* 
 * INDEX: IdMunicipio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresas') AND name='IdMunicipio')
BEGIN
    DROP INDEX HL_Empresas.IdMunicipio
    PRINT '<<< DROPPED INDEX HL_Empresas.IdMunicipio >>>'
END
go

/* 
 * INDEX: IdIndustria 
 */

CREATE INDEX IdIndustria ON HL_Empresas(IdIndustria)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresas') AND name='IdIndustria')
    PRINT '<<< CREATED INDEX HL_Empresas.IdIndustria >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Empresas.IdIndustria >>>'
go

/* 
 * INDEX: IdMunicipio 
 */

CREATE INDEX IdMunicipio ON HL_Empresas(IdMunicipio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Empresas') AND name='IdMunicipio')
    PRINT '<<< CREATED INDEX HL_Empresas.IdMunicipio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Empresas.IdMunicipio >>>'
go

/* 
 * INDEX: IdTitulo 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Estudio_x_Solicitud') AND name='IdTitulo')
BEGIN
    DROP INDEX HL_Estudio_x_Solicitud.IdTitulo
    PRINT '<<< DROPPED INDEX HL_Estudio_x_Solicitud.IdTitulo >>>'
END
go

/* 
 * INDEX: IdSolicitud 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Estudio_x_Solicitud') AND name='IdSolicitud')
BEGIN
    DROP INDEX HL_Estudio_x_Solicitud.IdSolicitud
    PRINT '<<< DROPPED INDEX HL_Estudio_x_Solicitud.IdSolicitud >>>'
END
go

/* 
 * INDEX: IdTitulo 
 */

CREATE INDEX IdTitulo ON HL_Estudio_x_Solicitud(IdTitulo)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Estudio_x_Solicitud') AND name='IdTitulo')
    PRINT '<<< CREATED INDEX HL_Estudio_x_Solicitud.IdTitulo >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Estudio_x_Solicitud.IdTitulo >>>'
go

/* 
 * INDEX: IdSolicitud 
 */

CREATE INDEX IdSolicitud ON HL_Estudio_x_Solicitud(IdSolicitud)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Estudio_x_Solicitud') AND name='IdSolicitud')
    PRINT '<<< CREATED INDEX HL_Estudio_x_Solicitud.IdSolicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Estudio_x_Solicitud.IdSolicitud >>>'
go

/* 
 * INDEX: IdMicroemprendimiento 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Etapas') AND name='IdMicroemprendimiento')
BEGIN
    DROP INDEX HL_Etapas.IdMicroemprendimiento
    PRINT '<<< DROPPED INDEX HL_Etapas.IdMicroemprendimiento >>>'
END
go

/* 
 * INDEX: IdMicroemprendimiento 
 */

CREATE INDEX IdMicroemprendimiento ON HL_Etapas(IdMicroemprendimiento)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Etapas') AND name='IdMicroemprendimiento')
    PRINT '<<< CREATED INDEX HL_Etapas.IdMicroemprendimiento >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Etapas.IdMicroemprendimiento >>>'
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Familiares') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Familiares.IdPersona
    PRINT '<<< DROPPED INDEX HL_Familiares.IdPersona >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Familiares(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Familiares') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Familiares.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Familiares.IdPersona >>>'
go

/* 
 * INDEX: IdIdioma 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Idioma_x_Persona') AND name='IdIdioma')
BEGIN
    DROP INDEX HL_Idioma_x_Persona.IdIdioma
    PRINT '<<< DROPPED INDEX HL_Idioma_x_Persona.IdIdioma >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Idioma_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Idioma_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX HL_Idioma_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdIdioma 
 */

CREATE INDEX IdIdioma ON HL_Idioma_x_Persona(IdIdioma)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Idioma_x_Persona') AND name='IdIdioma')
    PRINT '<<< CREATED INDEX HL_Idioma_x_Persona.IdIdioma >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Idioma_x_Persona.IdIdioma >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Idioma_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Idioma_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Idioma_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Idioma_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdAreas 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Intereses_x_Persona') AND name='IdAreas')
BEGIN
    DROP INDEX HL_Intereses_x_Persona.IdAreas
    PRINT '<<< DROPPED INDEX HL_Intereses_x_Persona.IdAreas >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Intereses_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Intereses_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX HL_Intereses_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdAreas 
 */

CREATE INDEX IdAreas ON HL_Intereses_x_Persona(IdAreas)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Intereses_x_Persona') AND name='IdAreas')
    PRINT '<<< CREATED INDEX HL_Intereses_x_Persona.IdAreas >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Intereses_x_Persona.IdAreas >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Intereses_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Intereses_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Intereses_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Intereses_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdIndustria 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Microemprendimientos') AND name='IdIndustria')
BEGIN
    DROP INDEX HL_Microemprendimientos.IdIndustria
    PRINT '<<< DROPPED INDEX HL_Microemprendimientos.IdIndustria >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Microemprendimientos') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Microemprendimientos.IdPersona
    PRINT '<<< DROPPED INDEX HL_Microemprendimientos.IdPersona >>>'
END
go

/* 
 * INDEX: IdMunicipio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Microemprendimientos') AND name='IdMunicipio')
BEGIN
    DROP INDEX HL_Microemprendimientos.IdMunicipio
    PRINT '<<< DROPPED INDEX HL_Microemprendimientos.IdMunicipio >>>'
END
go

/* 
 * INDEX: IdIndustria 
 */

CREATE INDEX IdIndustria ON HL_Microemprendimientos(IdIndustria)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Microemprendimientos') AND name='IdIndustria')
    PRINT '<<< CREATED INDEX HL_Microemprendimientos.IdIndustria >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Microemprendimientos.IdIndustria >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Microemprendimientos(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Microemprendimientos') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Microemprendimientos.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Microemprendimientos.IdPersona >>>'
go

/* 
 * INDEX: IdMunicipio 
 */

CREATE INDEX IdMunicipio ON HL_Microemprendimientos(IdMunicipio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Microemprendimientos') AND name='IdMunicipio')
    PRINT '<<< CREATED INDEX HL_Microemprendimientos.IdMunicipio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Microemprendimientos.IdMunicipio >>>'
go

/* 
 * INDEX: IdPlan 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Plan_x_Empresa') AND name='IdPlan')
BEGIN
    DROP INDEX HL_Plan_x_Empresa.IdPlan
    PRINT '<<< DROPPED INDEX HL_Plan_x_Empresa.IdPlan >>>'
END
go

/* 
 * INDEX: IdEmpresa 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Plan_x_Empresa') AND name='IdEmpresa')
BEGIN
    DROP INDEX HL_Plan_x_Empresa.IdEmpresa
    PRINT '<<< DROPPED INDEX HL_Plan_x_Empresa.IdEmpresa >>>'
END
go

/* 
 * INDEX: IdPlan 
 */

CREATE INDEX IdPlan ON HL_Plan_x_Empresa(IdPlan)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Plan_x_Empresa') AND name='IdPlan')
    PRINT '<<< CREATED INDEX HL_Plan_x_Empresa.IdPlan >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Plan_x_Empresa.IdPlan >>>'
go

/* 
 * INDEX: IdEmpresa 
 */

CREATE INDEX IdEmpresa ON HL_Plan_x_Empresa(IdEmpresa)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Plan_x_Empresa') AND name='IdEmpresa')
    PRINT '<<< CREATED INDEX HL_Plan_x_Empresa.IdEmpresa >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Plan_x_Empresa.IdEmpresa >>>'
go

/* 
 * INDEX: IdPlan 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Plan_x_Persona') AND name='IdPlan')
BEGIN
    DROP INDEX HL_Plan_x_Persona.IdPlan
    PRINT '<<< DROPPED INDEX HL_Plan_x_Persona.IdPlan >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Plan_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Plan_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX HL_Plan_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdPlan 
 */

CREATE INDEX IdPlan ON HL_Plan_x_Persona(IdPlan)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Plan_x_Persona') AND name='IdPlan')
    PRINT '<<< CREATED INDEX HL_Plan_x_Persona.IdPlan >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Plan_x_Persona.IdPlan >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Plan_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Plan_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Plan_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Plan_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdCargos 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Solicitudes') AND name='IdCargos')
BEGIN
    DROP INDEX HL_Solicitudes.IdCargos
    PRINT '<<< DROPPED INDEX HL_Solicitudes.IdCargos >>>'
END
go

/* 
 * INDEX: IdEmpresa 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Solicitudes') AND name='IdEmpresa')
BEGIN
    DROP INDEX HL_Solicitudes.IdEmpresa
    PRINT '<<< DROPPED INDEX HL_Solicitudes.IdEmpresa >>>'
END
go

/* 
 * INDEX: IdAreas 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Solicitudes') AND name='IdAreas')
BEGIN
    DROP INDEX HL_Solicitudes.IdAreas
    PRINT '<<< DROPPED INDEX HL_Solicitudes.IdAreas >>>'
END
go

/* 
 * INDEX: IdMunicipio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Solicitudes') AND name='IdMunicipio')
BEGIN
    DROP INDEX HL_Solicitudes.IdMunicipio
    PRINT '<<< DROPPED INDEX HL_Solicitudes.IdMunicipio >>>'
END
go

/* 
 * INDEX: IdCargos 
 */

CREATE INDEX IdCargos ON HL_Solicitudes(IdCargos)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Solicitudes') AND name='IdCargos')
    PRINT '<<< CREATED INDEX HL_Solicitudes.IdCargos >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Solicitudes.IdCargos >>>'
go

/* 
 * INDEX: IdEmpresa 
 */

CREATE INDEX IdEmpresa ON HL_Solicitudes(IdEmpresa)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Solicitudes') AND name='IdEmpresa')
    PRINT '<<< CREATED INDEX HL_Solicitudes.IdEmpresa >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Solicitudes.IdEmpresa >>>'
go

/* 
 * INDEX: IdAreas 
 */

CREATE INDEX IdAreas ON HL_Solicitudes(IdAreas)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Solicitudes') AND name='IdAreas')
    PRINT '<<< CREATED INDEX HL_Solicitudes.IdAreas >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Solicitudes.IdAreas >>>'
go

/* 
 * INDEX: IdMunicipio 
 */

CREATE INDEX IdMunicipio ON HL_Solicitudes(IdMunicipio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Solicitudes') AND name='IdMunicipio')
    PRINT '<<< CREATED INDEX HL_Solicitudes.IdMunicipio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Solicitudes.IdMunicipio >>>'
go

/* 
 * INDEX: IdTitulo 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Titulo_x_Persona') AND name='IdTitulo')
BEGIN
    DROP INDEX HL_Titulo_x_Persona.IdTitulo
    PRINT '<<< DROPPED INDEX HL_Titulo_x_Persona.IdTitulo >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Titulo_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX HL_Titulo_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX HL_Titulo_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdTitulo 
 */

CREATE INDEX IdTitulo ON HL_Titulo_x_Persona(IdTitulo)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Titulo_x_Persona') AND name='IdTitulo')
    PRINT '<<< CREATED INDEX HL_Titulo_x_Persona.IdTitulo >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Titulo_x_Persona.IdTitulo >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON HL_Titulo_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Titulo_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX HL_Titulo_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Titulo_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdEstudio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Titulos') AND name='IdEstudio')
BEGIN
    DROP INDEX HL_Titulos.IdEstudio
    PRINT '<<< DROPPED INDEX HL_Titulos.IdEstudio >>>'
END
go

/* 
 * INDEX: IdEstudio 
 */

CREATE INDEX IdEstudio ON HL_Titulos(IdEstudio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Titulos') AND name='IdEstudio')
    PRINT '<<< CREATED INDEX HL_Titulos.IdEstudio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Titulos.IdEstudio >>>'
go

/* 
 * INDEX: IdEmpresa 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Visita_Solicitud') AND name='IdEmpresa')
BEGIN
    DROP INDEX HL_Visita_Solicitud.IdEmpresa
    PRINT '<<< DROPPED INDEX HL_Visita_Solicitud.IdEmpresa >>>'
END
go

/* 
 * INDEX: IdSolicitud 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Visita_Solicitud') AND name='IdSolicitud')
BEGIN
    DROP INDEX HL_Visita_Solicitud.IdSolicitud
    PRINT '<<< DROPPED INDEX HL_Visita_Solicitud.IdSolicitud >>>'
END
go

/* 
 * INDEX: IdEmpresa 
 */

CREATE INDEX IdEmpresa ON HL_Visita_Solicitud(IdEmpresa)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Visita_Solicitud') AND name='IdEmpresa')
    PRINT '<<< CREATED INDEX HL_Visita_Solicitud.IdEmpresa >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Visita_Solicitud.IdEmpresa >>>'
go

/* 
 * INDEX: IdSolicitud 
 */

CREATE INDEX IdSolicitud ON HL_Visita_Solicitud(IdSolicitud)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('HL_Visita_Solicitud') AND name='IdSolicitud')
    PRINT '<<< CREATED INDEX HL_Visita_Solicitud.IdSolicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX HL_Visita_Solicitud.IdSolicitud >>>'
go

/* 
 * TABLE: HL_Bienes_x_Microemprendimiento 
 */

ALTER TABLE HL_Bienes_x_Microemprendimiento ADD CONSTRAINT RefHL_Microemprendimientos43 
    FOREIGN KEY (IdMicroemprendimiento)
    REFERENCES HL_Microemprendimientos(IdMicroemprendimiento) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Capacidad_x_Persona 
 */

ALTER TABLE HL_Capacidad_x_Persona ADD CONSTRAINT RefHL_Capacidades44 
    FOREIGN KEY (IdCapacidad)
    REFERENCES HL_Capacidades(IdCapacidad) ON DELETE CASCADE
go

ALTER TABLE HL_Capacidad_x_Persona ADD CONSTRAINT RefHL_Personas45 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Cargos 
 */

ALTER TABLE HL_Cargos ADD CONSTRAINT RefHL_Tipo_Puestos6 
    FOREIGN KEY (IdTipoPuesto)
    REFERENCES HL_Tipo_Puestos(IdTipoPuesto)
go


/* 
 * TABLE: HL_Carnet_x_Persona 
 */

ALTER TABLE HL_Carnet_x_Persona ADD CONSTRAINT RefHL_Carnet33 
    FOREIGN KEY (IdCarnet)
    REFERENCES HL_Carnet(IdCarnet) ON DELETE CASCADE
go

ALTER TABLE HL_Carnet_x_Persona ADD CONSTRAINT RefHL_Personas34 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Cobranzas 
 */

ALTER TABLE HL_Cobranzas ADD CONSTRAINT RefHL_Microemprendimientos47 
    FOREIGN KEY (IdMicroemprendimiento)
    REFERENCES HL_Microemprendimientos(IdMicroemprendimiento) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Cursos 
 */

ALTER TABLE HL_Cursos ADD CONSTRAINT RefHL_Convenios22 
    FOREIGN KEY (IdConvenio)
    REFERENCES HL_Convenios(IdConvenio) ON DELETE CASCADE
go

ALTER TABLE HL_Cursos ADD CONSTRAINT RefHL_Area_Cursos58 
    FOREIGN KEY (IdAreaCurso)
    REFERENCES HL_Area_Cursos(IdAreaCurso)
go


/* 
 * TABLE: HL_Cursos_Deseados_x_Persona 
 */

ALTER TABLE HL_Cursos_Deseados_x_Persona ADD CONSTRAINT RefHL_Personas24 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go

ALTER TABLE HL_Cursos_Deseados_x_Persona ADD CONSTRAINT RefHL_Cursos59 
    FOREIGN KEY (IdCurso)
    REFERENCES HL_Cursos(IdCurso) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Cursos_x_Persona 
 */

ALTER TABLE HL_Cursos_x_Persona ADD CONSTRAINT RefHL_Personas26 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go

ALTER TABLE HL_Cursos_x_Persona ADD CONSTRAINT RefHL_Cursos54 
    FOREIGN KEY (IdCurso)
    REFERENCES HL_Cursos(IdCurso) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Discapacidad_x_Familiar 
 */

ALTER TABLE HL_Discapacidad_x_Familiar ADD CONSTRAINT RefHL_Discapacidades41 
    FOREIGN KEY (IdDiscapacidad)
    REFERENCES HL_Discapacidades(IdDiscapacidad) ON DELETE CASCADE
go

ALTER TABLE HL_Discapacidad_x_Familiar ADD CONSTRAINT RefHL_Familiares42 
    FOREIGN KEY (IdFamiliar)
    REFERENCES HL_Familiares(IdFamiliar) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Discapacidad_x_Solicitud 
 */

ALTER TABLE HL_Discapacidad_x_Solicitud ADD CONSTRAINT RefHL_Discapacidades49 
    FOREIGN KEY (IdDiscapacidad)
    REFERENCES HL_Discapacidades(IdDiscapacidad) ON DELETE CASCADE
go

ALTER TABLE HL_Discapacidad_x_Solicitud ADD CONSTRAINT RefHL_Solicitudes50 
    FOREIGN KEY (IdSolicitud)
    REFERENCES HL_Solicitudes(IdSolicitud) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Discapacidades 
 */

ALTER TABLE HL_Discapacidades ADD CONSTRAINT RefHL_Tipo_Discapacidades38 
    FOREIGN KEY (IdTipoDiscapacidad)
    REFERENCES HL_Tipo_Discapacidades(IdTipoDiscapacidad) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Discapacidades_x_Persona 
 */

ALTER TABLE HL_Discapacidades_x_Persona ADD CONSTRAINT RefHL_Discapacidades39 
    FOREIGN KEY (IdDiscapacidad)
    REFERENCES HL_Discapacidades(IdDiscapacidad) ON DELETE CASCADE
go

ALTER TABLE HL_Discapacidades_x_Persona ADD CONSTRAINT RefHL_Personas40 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Empresa_x_Persona_x_Cargo 
 */

ALTER TABLE HL_Empresa_x_Persona_x_Cargo ADD CONSTRAINT RefHL_Cargos7 
    FOREIGN KEY (IdCargos)
    REFERENCES HL_Cargos(IdCargos) ON DELETE CASCADE
go

ALTER TABLE HL_Empresa_x_Persona_x_Cargo ADD CONSTRAINT RefHL_Areas8 
    FOREIGN KEY (IdAreas)
    REFERENCES HL_Areas(IdAreas)
go

ALTER TABLE HL_Empresa_x_Persona_x_Cargo ADD CONSTRAINT RefHL_Solicitudes10 
    FOREIGN KEY (IdSolicitud)
    REFERENCES HL_Solicitudes(IdSolicitud)
go

ALTER TABLE HL_Empresa_x_Persona_x_Cargo ADD CONSTRAINT RefHL_Empresas11 
    FOREIGN KEY (IdEmpresa)
    REFERENCES HL_Empresas(IdEmpresa) ON DELETE CASCADE
go

ALTER TABLE HL_Empresa_x_Persona_x_Cargo ADD CONSTRAINT RefHL_Personas12 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Empresas 
 */

ALTER TABLE HL_Empresas ADD CONSTRAINT RefHL_Municipios28 
    FOREIGN KEY (IdMunicipio)
    REFERENCES HL_Municipios(IdMunicipio)
go

ALTER TABLE HL_Empresas ADD CONSTRAINT RefHL_Industrias13 
    FOREIGN KEY (IdIndustria)
    REFERENCES HL_Industrias(IdIndustria)
go


/* 
 * TABLE: HL_Estudio_x_Solicitud 
 */

ALTER TABLE HL_Estudio_x_Solicitud ADD CONSTRAINT RefHL_Titulos3 
    FOREIGN KEY (IdTitulo)
    REFERENCES HL_Titulos(IdTitulo) ON DELETE CASCADE
go

ALTER TABLE HL_Estudio_x_Solicitud ADD CONSTRAINT RefHL_Solicitudes4 
    FOREIGN KEY (IdSolicitud)
    REFERENCES HL_Solicitudes(IdSolicitud) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Etapas 
 */

ALTER TABLE HL_Etapas ADD CONSTRAINT RefHL_Microemprendimientos46 
    FOREIGN KEY (IdMicroemprendimiento)
    REFERENCES HL_Microemprendimientos(IdMicroemprendimiento) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Familiares 
 */

ALTER TABLE HL_Familiares ADD CONSTRAINT RefHL_Personas37 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Idioma_x_Persona 
 */

ALTER TABLE HL_Idioma_x_Persona ADD CONSTRAINT RefHL_Idiomas35 
    FOREIGN KEY (IdIdioma)
    REFERENCES HL_Idiomas(IdIdioma) ON DELETE CASCADE
go

ALTER TABLE HL_Idioma_x_Persona ADD CONSTRAINT RefHL_Personas36 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Intereses_x_Persona 
 */

ALTER TABLE HL_Intereses_x_Persona ADD CONSTRAINT RefHL_Areas31 
    FOREIGN KEY (IdAreas)
    REFERENCES HL_Areas(IdAreas) ON DELETE CASCADE
go

ALTER TABLE HL_Intereses_x_Persona ADD CONSTRAINT RefHL_Personas32 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Microemprendimientos 
 */

ALTER TABLE HL_Microemprendimientos ADD CONSTRAINT RefHL_Municipios30 
    FOREIGN KEY (IdMunicipio)
    REFERENCES HL_Municipios(IdMunicipio)
go

ALTER TABLE HL_Microemprendimientos ADD CONSTRAINT RefHL_Industrias55 
    FOREIGN KEY (IdIndustria)
    REFERENCES HL_Industrias(IdIndustria)
go

ALTER TABLE HL_Microemprendimientos ADD CONSTRAINT RefHL_Personas56 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Personas 
 */

ALTER TABLE HL_Personas ADD CONSTRAINT RefHL_Municipios29 
    FOREIGN KEY (IdMunicipio)
    REFERENCES HL_Municipios(IdMunicipio)
go


/* 
 * TABLE: HL_Plan_x_Empresa 
 */

ALTER TABLE HL_Plan_x_Empresa ADD CONSTRAINT RefHL_Empresas15 
    FOREIGN KEY (IdEmpresa)
    REFERENCES HL_Empresas(IdEmpresa) ON DELETE CASCADE
go

ALTER TABLE HL_Plan_x_Empresa ADD CONSTRAINT RefHL_Planes14 
    FOREIGN KEY (IdPlan)
    REFERENCES HL_Planes(IdPlan) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Plan_x_Persona 
 */

ALTER TABLE HL_Plan_x_Persona ADD CONSTRAINT RefHL_Planes16 
    FOREIGN KEY (IdPlan)
    REFERENCES HL_Planes(IdPlan) ON DELETE CASCADE
go

ALTER TABLE HL_Plan_x_Persona ADD CONSTRAINT RefHL_Personas17 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Solicitudes 
 */

ALTER TABLE HL_Solicitudes ADD CONSTRAINT RefHL_Municipios27 
    FOREIGN KEY (IdMunicipio)
    REFERENCES HL_Municipios(IdMunicipio)
go

ALTER TABLE HL_Solicitudes ADD CONSTRAINT RefHL_Cargos52 
    FOREIGN KEY (IdCargos)
    REFERENCES HL_Cargos(IdCargos)
go

ALTER TABLE HL_Solicitudes ADD CONSTRAINT RefHL_Empresas57 
    FOREIGN KEY (IdEmpresa)
    REFERENCES HL_Empresas(IdEmpresa)
go

ALTER TABLE HL_Solicitudes ADD CONSTRAINT RefHL_Areas9 
    FOREIGN KEY (IdAreas)
    REFERENCES HL_Areas(IdAreas)
go


/* 
 * TABLE: HL_Titulo_x_Persona 
 */

ALTER TABLE HL_Titulo_x_Persona ADD CONSTRAINT RefHL_Titulos18 
    FOREIGN KEY (IdTitulo)
    REFERENCES HL_Titulos(IdTitulo) ON DELETE CASCADE
go

ALTER TABLE HL_Titulo_x_Persona ADD CONSTRAINT RefHL_Personas19 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Titulos 
 */

ALTER TABLE HL_Titulos ADD CONSTRAINT RefHL_Estudios5 
    FOREIGN KEY (IdEstudio)
    REFERENCES HL_Estudios(IdEstudio) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Trabajos_Domesticos 
 */

ALTER TABLE HL_Trabajos_Domesticos ADD CONSTRAINT RefHL_Empresas63 
    FOREIGN KEY (IdEmpresa)
    REFERENCES HL_Empresas(IdEmpresa)
go

ALTER TABLE HL_Trabajos_Domesticos ADD CONSTRAINT RefHL_Personas64 
    FOREIGN KEY (IdPersona)
    REFERENCES HL_Personas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Usuarios 
 */

ALTER TABLE HL_Usuarios ADD CONSTRAINT RefHL_Municipios65 
    FOREIGN KEY (IdMunicipio)
    REFERENCES HL_Municipios(IdMunicipio)
go


/* 
 * TABLE: HL_Visita_Solicitud 
 */

ALTER TABLE HL_Visita_Solicitud ADD CONSTRAINT RefHL_Empresas51 
    FOREIGN KEY (IdEmpresa)
    REFERENCES HL_Empresas(IdEmpresa) ON DELETE CASCADE
go

ALTER TABLE HL_Visita_Solicitud ADD CONSTRAINT RefHL_Solicitudes1 
    FOREIGN KEY (IdSolicitud)
    REFERENCES HL_Solicitudes(IdSolicitud) ON DELETE CASCADE
go


/* 
 * TABLE: HL_Visitas 
 */

ALTER TABLE HL_Visitas ADD CONSTRAINT RefHL_Etapas48 
    FOREIGN KEY (IdEtapas)
    REFERENCES HL_Etapas(IdEtapas) ON DELETE CASCADE
go


/* 
 * TRIGGER: HL_Area_CursosDelTrig 
 */

CREATE TRIGGER HL_Area_CursosDelTrig ON HL_Area_Cursos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE HL_Cursos SET
            IdAreaCurso = NULL
        FROM HL_Cursos ch, deleted
        WHERE
            ch.IdAreaCurso = deleted.IdAreaCurso

END
go

go
IF OBJECT_ID('HL_Area_CursosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_Area_CursosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_Area_CursosDelTrig >>>'
go


/* 
 * TRIGGER: HL_AreasDelTrig 
 */

CREATE TRIGGER HL_AreasDelTrig ON HL_Areas
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE HL_Empresa_x_Persona_x_Cargo SET
            IdAreas = NULL
        FROM HL_Empresa_x_Persona_x_Cargo ch, deleted
        WHERE
            ch.IdAreas = deleted.IdAreas
-- Parent Delete: SET NULL

    UPDATE HL_Solicitudes SET
            IdAreas = NULL
        FROM HL_Solicitudes ch, deleted
        WHERE
            ch.IdAreas = deleted.IdAreas
-- Parent Delete: CASCADE

    DELETE HL_Intereses_x_Persona
        FROM HL_Intereses_x_Persona ch, deleted
        WHERE ch.IdAreas = deleted.IdAreas

END
go

go
IF OBJECT_ID('HL_AreasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_AreasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_AreasDelTrig >>>'
go


/* 
 * TRIGGER: HL_CapacidadesDelTrig 
 */

CREATE TRIGGER HL_CapacidadesDelTrig ON HL_Capacidades
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Capacidad_x_Persona
        FROM HL_Capacidad_x_Persona ch, deleted
        WHERE ch.IdCapacidad = deleted.IdCapacidad

END
go

go
IF OBJECT_ID('HL_CapacidadesDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_CapacidadesDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_CapacidadesDelTrig >>>'
go


/* 
 * TRIGGER: HL_CargosDelTrig 
 */

CREATE TRIGGER HL_CargosDelTrig ON HL_Cargos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Empresa_x_Persona_x_Cargo
        FROM HL_Empresa_x_Persona_x_Cargo ch, deleted
        WHERE ch.IdCargos = deleted.IdCargos
-- Parent Delete: SET NULL

    UPDATE HL_Solicitudes SET
            IdCargos = NULL
        FROM HL_Solicitudes ch, deleted
        WHERE
            ch.IdCargos = deleted.IdCargos

END
go

go
IF OBJECT_ID('HL_CargosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_CargosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_CargosDelTrig >>>'
go


/* 
 * TRIGGER: HL_CarnetDelTrig 
 */

CREATE TRIGGER HL_CarnetDelTrig ON HL_Carnet
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Carnet_x_Persona
        FROM HL_Carnet_x_Persona ch, deleted
        WHERE ch.IdCarnet = deleted.IdCarnet

END
go

go
IF OBJECT_ID('HL_CarnetDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_CarnetDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_CarnetDelTrig >>>'
go


/* 
 * TRIGGER: HL_ConveniosDelTrig 
 */

CREATE TRIGGER HL_ConveniosDelTrig ON HL_Convenios
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Cursos
        FROM HL_Cursos ch, deleted
        WHERE ch.IdConvenio = deleted.IdConvenio

END
go

go
IF OBJECT_ID('HL_ConveniosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_ConveniosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_ConveniosDelTrig >>>'
go


/* 
 * TRIGGER: HL_CursosDelTrig 
 */

CREATE TRIGGER HL_CursosDelTrig ON HL_Cursos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Cursos_Deseados_x_Persona
        FROM HL_Cursos_Deseados_x_Persona ch, deleted
        WHERE ch.IdCurso = deleted.IdCurso
-- Parent Delete: CASCADE

    DELETE HL_Cursos_x_Persona
        FROM HL_Cursos_x_Persona ch, deleted
        WHERE ch.IdCurso = deleted.IdCurso

END
go

go
IF OBJECT_ID('HL_CursosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_CursosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_CursosDelTrig >>>'
go


/* 
 * TRIGGER: HL_DiscapacidadesDelTrig 
 */

CREATE TRIGGER HL_DiscapacidadesDelTrig ON HL_Discapacidades
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Discapacidades_x_Persona
        FROM HL_Discapacidades_x_Persona ch, deleted
        WHERE ch.IdDiscapacidad = deleted.IdDiscapacidad
-- Parent Delete: CASCADE

    DELETE HL_Discapacidad_x_Familiar
        FROM HL_Discapacidad_x_Familiar ch, deleted
        WHERE ch.IdDiscapacidad = deleted.IdDiscapacidad
-- Parent Delete: CASCADE

    DELETE HL_Discapacidad_x_Solicitud
        FROM HL_Discapacidad_x_Solicitud ch, deleted
        WHERE ch.IdDiscapacidad = deleted.IdDiscapacidad

END
go

go
IF OBJECT_ID('HL_DiscapacidadesDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_DiscapacidadesDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_DiscapacidadesDelTrig >>>'
go


/* 
 * TRIGGER: HL_EmpresasDelTrig 
 */

CREATE TRIGGER HL_EmpresasDelTrig ON HL_Empresas
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE HL_Solicitudes SET
            IdEmpresa = NULL
        FROM HL_Solicitudes ch, deleted
        WHERE
            ch.IdEmpresa = deleted.IdEmpresa
-- Parent Delete: CASCADE

    DELETE HL_Empresa_x_Persona_x_Cargo
        FROM HL_Empresa_x_Persona_x_Cargo ch, deleted
        WHERE ch.IdEmpresa = deleted.IdEmpresa
-- Parent Delete: CASCADE

    DELETE HL_Plan_x_Empresa
        FROM HL_Plan_x_Empresa ch, deleted
        WHERE ch.IdEmpresa = deleted.IdEmpresa
-- Parent Delete: CASCADE

    DELETE HL_Visita_Solicitud
        FROM HL_Visita_Solicitud ch, deleted
        WHERE ch.IdEmpresa = deleted.IdEmpresa

END
go

go
IF OBJECT_ID('HL_EmpresasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_EmpresasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_EmpresasDelTrig >>>'
go


/* 
 * TRIGGER: HL_EstudiosDelTrig 
 */

CREATE TRIGGER HL_EstudiosDelTrig ON HL_Estudios
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Titulos
        FROM HL_Titulos ch, deleted
        WHERE ch.IdEstudio = deleted.IdEstudio

END
go

go
IF OBJECT_ID('HL_EstudiosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_EstudiosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_EstudiosDelTrig >>>'
go


/* 
 * TRIGGER: HL_EtapasDelTrig 
 */

CREATE TRIGGER HL_EtapasDelTrig ON HL_Etapas
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Visitas
        FROM HL_Visitas ch, deleted
        WHERE ch.IdEtapas = deleted.IdEtapas

END
go

go
IF OBJECT_ID('HL_EtapasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_EtapasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_EtapasDelTrig >>>'
go


/* 
 * TRIGGER: HL_FamiliaresDelTrig 
 */

CREATE TRIGGER HL_FamiliaresDelTrig ON HL_Familiares
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Discapacidad_x_Familiar
        FROM HL_Discapacidad_x_Familiar ch, deleted
        WHERE ch.IdFamiliar = deleted.IdFamiliar

END
go

go
IF OBJECT_ID('HL_FamiliaresDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_FamiliaresDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_FamiliaresDelTrig >>>'
go


/* 
 * TRIGGER: HL_IdiomasDelTrig 
 */

CREATE TRIGGER HL_IdiomasDelTrig ON HL_Idiomas
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Idioma_x_Persona
        FROM HL_Idioma_x_Persona ch, deleted
        WHERE ch.IdIdioma = deleted.IdIdioma

END
go

go
IF OBJECT_ID('HL_IdiomasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_IdiomasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_IdiomasDelTrig >>>'
go


/* 
 * TRIGGER: HL_IndustriasDelTrig 
 */

CREATE TRIGGER HL_IndustriasDelTrig ON HL_Industrias
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE HL_Empresas SET
            IdIndustria = NULL
        FROM HL_Empresas ch, deleted
        WHERE
            ch.IdIndustria = deleted.IdIndustria
-- Parent Delete: SET NULL

    UPDATE HL_Microemprendimientos SET
            IdIndustria = NULL
        FROM HL_Microemprendimientos ch, deleted
        WHERE
            ch.IdIndustria = deleted.IdIndustria

END
go

go
IF OBJECT_ID('HL_IndustriasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_IndustriasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_IndustriasDelTrig >>>'
go


/* 
 * TRIGGER: HL_MicroemprendimientosDelTrig 
 */

CREATE TRIGGER HL_MicroemprendimientosDelTrig ON HL_Microemprendimientos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Bienes_x_Microemprendimiento
        FROM HL_Bienes_x_Microemprendimiento ch, deleted
        WHERE ch.IdMicroemprendimiento = deleted.IdMicroemprendimiento
-- Parent Delete: CASCADE

    DELETE HL_Etapas
        FROM HL_Etapas ch, deleted
        WHERE ch.IdMicroemprendimiento = deleted.IdMicroemprendimiento
-- Parent Delete: CASCADE

    DELETE HL_Cobranzas
        FROM HL_Cobranzas ch, deleted
        WHERE ch.IdMicroemprendimiento = deleted.IdMicroemprendimiento

END
go

go
IF OBJECT_ID('HL_MicroemprendimientosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_MicroemprendimientosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_MicroemprendimientosDelTrig >>>'
go


/* 
 * TRIGGER: HL_MunicipiosDelTrig 
 */

CREATE TRIGGER HL_MunicipiosDelTrig ON HL_Municipios
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE HL_Solicitudes SET
            IdMunicipio = NULL
        FROM HL_Solicitudes ch, deleted
        WHERE
            ch.IdMunicipio = deleted.IdMunicipio
-- Parent Delete: SET NULL

    UPDATE HL_Empresas SET
            IdMunicipio = NULL
        FROM HL_Empresas ch, deleted
        WHERE
            ch.IdMunicipio = deleted.IdMunicipio
-- Parent Delete: SET NULL

    UPDATE HL_Personas SET
            IdMunicipio = NULL
        FROM HL_Personas ch, deleted
        WHERE
            ch.IdMunicipio = deleted.IdMunicipio
-- Parent Delete: SET NULL

    UPDATE HL_Microemprendimientos SET
            IdMunicipio = NULL
        FROM HL_Microemprendimientos ch, deleted
        WHERE
            ch.IdMunicipio = deleted.IdMunicipio

END
go

go
IF OBJECT_ID('HL_MunicipiosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_MunicipiosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_MunicipiosDelTrig >>>'
go


/* 
 * TRIGGER: HL_PersonasDelTrig 
 */

CREATE TRIGGER HL_PersonasDelTrig ON HL_Personas
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Empresa_x_Persona_x_Cargo
        FROM HL_Empresa_x_Persona_x_Cargo ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Trabajos_Domesticos
        FROM HL_Trabajos_Domesticos ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Plan_x_Persona
        FROM HL_Plan_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Titulo_x_Persona
        FROM HL_Titulo_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Cursos_Deseados_x_Persona
        FROM HL_Cursos_Deseados_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Cursos_x_Persona
        FROM HL_Cursos_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Intereses_x_Persona
        FROM HL_Intereses_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Carnet_x_Persona
        FROM HL_Carnet_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Idioma_x_Persona
        FROM HL_Idioma_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Familiares
        FROM HL_Familiares ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Discapacidades_x_Persona
        FROM HL_Discapacidades_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Capacidad_x_Persona
        FROM HL_Capacidad_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE HL_Microemprendimientos
        FROM HL_Microemprendimientos ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona

END
go

go
IF OBJECT_ID('HL_PersonasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_PersonasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_PersonasDelTrig >>>'
go


/* 
 * TRIGGER: HL_PlanesDelTrig 
 */

CREATE TRIGGER HL_PlanesDelTrig ON HL_Planes
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Plan_x_Empresa
        FROM HL_Plan_x_Empresa ch, deleted
        WHERE ch.IdPlan = deleted.IdPlan
-- Parent Delete: CASCADE

    DELETE HL_Plan_x_Persona
        FROM HL_Plan_x_Persona ch, deleted
        WHERE ch.IdPlan = deleted.IdPlan

END
go

go
IF OBJECT_ID('HL_PlanesDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_PlanesDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_PlanesDelTrig >>>'
go


/* 
 * TRIGGER: HL_SolicitudesDelTrig 
 */

CREATE TRIGGER HL_SolicitudesDelTrig ON HL_Solicitudes
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE HL_Empresa_x_Persona_x_Cargo SET
            IdSolicitud = NULL
        FROM HL_Empresa_x_Persona_x_Cargo ch, deleted
        WHERE
            ch.IdSolicitud = deleted.IdSolicitud
-- Parent Delete: CASCADE

    DELETE HL_Discapacidad_x_Solicitud
        FROM HL_Discapacidad_x_Solicitud ch, deleted
        WHERE ch.IdSolicitud = deleted.IdSolicitud
-- Parent Delete: CASCADE

    DELETE HL_Visita_Solicitud
        FROM HL_Visita_Solicitud ch, deleted
        WHERE ch.IdSolicitud = deleted.IdSolicitud
-- Parent Delete: CASCADE

    DELETE HL_Estudio_x_Solicitud
        FROM HL_Estudio_x_Solicitud ch, deleted
        WHERE ch.IdSolicitud = deleted.IdSolicitud

END
go

go
IF OBJECT_ID('HL_SolicitudesDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_SolicitudesDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_SolicitudesDelTrig >>>'
go


/* 
 * TRIGGER: HL_Tipo_DiscapacidadesDelTrig 
 */

CREATE TRIGGER HL_Tipo_DiscapacidadesDelTrig ON HL_Tipo_Discapacidades
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Discapacidades
        FROM HL_Discapacidades ch, deleted
        WHERE ch.IdTipoDiscapacidad = deleted.IdTipoDiscapacidad

END
go

go
IF OBJECT_ID('HL_Tipo_DiscapacidadesDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_Tipo_DiscapacidadesDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_Tipo_DiscapacidadesDelTrig >>>'
go


/* 
 * TRIGGER: HL_Tipo_PuestosDelTrig 
 */

CREATE TRIGGER HL_Tipo_PuestosDelTrig ON HL_Tipo_Puestos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE HL_Cargos SET
            IdTipoPuesto = NULL
        FROM HL_Cargos ch, deleted
        WHERE
            ch.IdTipoPuesto = deleted.IdTipoPuesto

END
go

go
IF OBJECT_ID('HL_Tipo_PuestosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_Tipo_PuestosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_Tipo_PuestosDelTrig >>>'
go


/* 
 * TRIGGER: HL_TitulosDelTrig 
 */

CREATE TRIGGER HL_TitulosDelTrig ON HL_Titulos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE HL_Titulo_x_Persona
        FROM HL_Titulo_x_Persona ch, deleted
        WHERE ch.IdTitulo = deleted.IdTitulo
-- Parent Delete: CASCADE

    DELETE HL_Estudio_x_Solicitud
        FROM HL_Estudio_x_Solicitud ch, deleted
        WHERE ch.IdTitulo = deleted.IdTitulo

END
go

go
IF OBJECT_ID('HL_TitulosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER HL_TitulosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER HL_TitulosDelTrig >>>'
go


